# -*- makefile -*-

# Targets useful for maintenance/making releases etc. Some of them depend
# on very specific local setups

include Makefile

rpmbuild_dir=/data/rpmbuild/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
rpb_spec=$(rpmbuild_dir)/augeas.spec
release_dir=weave:/var/www/sites/download.augeas.net/

tarball=$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz

# This only works with the way I have set up my .rpmmacros
build-rpm:
	test -d $(rpmbuild_dir) || mkdir $(rpmbuild_dir)
	rm -f $(rpmbuild_dir)/$(tarball) $(rpb_spec)
	ln -sf $(abs_top_srcdir)/$(tarball) $(rpmbuild_dir)
	ln -sf $(abs_top_srcdir)/augeas.spec $(rpmbuild_dir)
	rpmbuild -ba $(rpmbuild_dir)/augeas.spec

upload:
	@gpg -q --batch --verify $(tarball).sig > /dev/null 2>&1 || \
	  gpg --output $(tarball).sig --detach-sig $(tarball);      \
	rsync -v $(tarball) $(tarball).sig $(release_dir);          \
	git push --tags

tag-release:
	@git tag -s release-$(VERSION)

# Print all the debug categories in use
debug-categories:
	@fgrep 'debugging("' src/*.c | sed -r -e 's/^.*debugging\("([^"]+)"\).*$$/\1/' | sort -u

# This is how I run autogen.sh locally
autogen:
	./autogen.sh CFLAGS=-g --prefix=/data/share/ --gnulib-srcdir=${HOME}/code/gnulib/ --enable-compile-warnings=error --enable-debug=yes

.PHONY: build-rpm
